<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查找</title>
</head>

<body>
    <script>
        let ary = [{
                id: 1,
                name: "张三"
            },
            {
                id: 2,
                name: "李四"
            }
        ]
        let target = ary.find((item, index) => item.id == 2)
        console.log(target);

        let ary1 = [1, 5, 12, 56, 78]
        let index = ary1.findIndex((item, index) => item > 20)
        console.log(index);
    </script>
</body>

</html>